<!DOCTYPE HTML>
<html lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
    <!--Setting-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable" content="我是一条老鱼">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,adress=no">
    <meta name="browsermode" content="application">
    <meta name="screen-orientation" content="portrait">
    <meta name="theme-version" content="1.2.3">
    <meta name="root" content="/blog/">
    <link rel="dns-prefetch" href="http://lexizhi.gitee.io/blog">
    <!--SEO-->

    <meta name="keywords" content="HTML">


    <meta name="description" content="为何使用Gitee而不是GitHub目前国内访问GitHub速度慢，还可能被墙，所以Gitee来构建个人博客。Gitee类似国内版的GitHub，访问速度有保证。
环境要求：
Git 
Node...">



<meta name="robots" content="all">
<meta name="google" content="all">
<meta name="googlebot" content="all">
<meta name="verify" content="all">

    <!--Title-->


<title>使用Gitee+Hexo搭建个人博客 | 我是一条老鱼</title>


    <link rel="alternate" href="/atom.xml" title="我是一条老鱼" type="application/atom+xml">


    <link rel="icon" href="/favicon.ico">

    



<link rel="stylesheet" href="/blog/css/bootstrap.min.css?rev=3.3.7">
<link rel="stylesheet" href="/blog/css/font-awesome.min.css?rev=4.5.0">
<link rel="stylesheet" href="/blog/css/style.css?rev=@@hash">




    
	<div class="hide">
		<script type="text/javascript">
			var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan class='cnzz_stat_icon_1263868967 hide' %3E%3Cscript%20src%3D%22https%3A%2F%2Fs95.cnzz.com%2Fz_stat.php%3Fweb_id%3D1272564536%22%3E%3C%2Fscript%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1263868967%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));
		</script>
	</div>






    

<link rel="stylesheet" href="/blog/css/prism-tomorrow.css" type="text/css"></head>

</html>
<!--[if lte IE 8]>
<style>
    html{ font-size: 1em }
</style>
<![endif]-->
<!--[if lte IE 9]>
<div style="ie">你使用的浏览器版本过低，为了你更好的阅读体验，请更新浏览器的版本或者使用其他现代浏览器，比如Chrome、Firefox、Safari等。</div>
<![endif]-->

<body>
    <header class="main-header" style="background-image:url(http://snippet.shenliyang.com/img/banner.jpg)">
    <div class="main-header-box">
        <a class="header-avatar" href="/" title="LaoYu">
            <img src="/blog/img/avatar.jpg" alt="logo头像" class="img-responsive center-block">
        </a>
        <div class="branding">
        	<!--<h2 class="text-hide">Snippet主题,从未如此简单有趣</h2>-->
            
                <h2> 学编程从未如此简单有趣 </h2>
            
    	</div>
    </div>
</header>
    <nav class="main-navigation">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="navbar-header"><span class="nav-toggle-button collapsed pull-right" data-toggle="collapse" data-target="#main-menu" id="mnav">
                    <span class="sr-only"></span>
                        <i class="fa fa-bars"></i>
                    </span>
                    <a class="navbar-brand" href="http://lexizhi.gitee.io/blog">我是一条老鱼</a>
                </div>
                <div class="collapse navbar-collapse" id="main-menu">
                    <ul class="menu">
                        
                            <li role="presentation" class="text-center">
                                <a href="/blog"><i class="fa "></i>首页</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/categories/h5/"><i class="fa "></i>web前端</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/categories/后端/"><i class="fa "></i>后端</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/categories/工具/"><i class="fa "></i>工具</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/archives/"><i class="fa "></i>时间轴</a>
                            </li>
                        
                    </ul>
                </div>
            </div>
        </div>
    </div>
</nav>
    <section class="content-wrap">
        <div class="container">
            <div class="row">
                <main class="col-md-8 main-content m-post">
                    <p id="process"></p>
<article class="post">
    <div class="post-head">
        <h1 id="使用Gitee+Hexo搭建个人博客">
            
	            使用Gitee+Hexo搭建个人博客
            
        </h1>
        <div class="post-meta">
    
        <span class="categories-meta fa-wrap">
            <i class="fa fa-folder-open-o"></i>
            <a class="category-link" href="/blog/categories/教程/">教程</a>
        </span>
    

    
        <span class="fa-wrap">
            <i class="fa fa-tags"></i>
            <span class="tags-meta">
                
                    <a class="tag-link" href="/blog/tags/HTML/">HTML</a>
                
            </span>
        </span>
    

    
        
        <span class="fa-wrap">
            <i class="fa fa-clock-o"></i>
            <span class="date-meta">2019/05/26</span>
        </span>
        
            <span class="fa-wrap">
                <i class="fa fa-eye"></i>
                <span id="busuanzi_value_page_pv"></span>
            </span>
        
    
</div>
            
            
    </div>
    
    <div class="post-body post-content">
        <h2 id="为何使用Gitee而不是GitHub"><a href="#为何使用Gitee而不是GitHub" class="headerlink" title="为何使用Gitee而不是GitHub"></a>为何使用Gitee而不是GitHub</h2><p>目前国内访问GitHub速度慢，还可能被墙，所以Gitee来构建个人博客。Gitee类似国内版的GitHub，访问速度有保证。</p>
<pre class=" language-bash"><code class="language-bash">环境要求：
Git 
NodeJs 
默认你已经安装了Git和NodeJS<span class="token punctuation">(</span>推荐使用cnpm<span class="token punctuation">)</span>
</code></pre>
<h2 id="开始搭建"><a href="#开始搭建" class="headerlink" title="开始搭建"></a>开始搭建</h2><h3 id="1-安装Hexo"><a href="#1-安装Hexo" class="headerlink" title="1. 安装Hexo"></a>1. 安装Hexo</h3><p>打开cmd，输入： <code>cnpm install -g hexo</code></p>
<p>cnpm 是淘宝的开源镜像，国内访问比npm快</p>
<h3 id="2-初始化Hexo"><a href="#2-初始化Hexo" class="headerlink" title="2. 初始化Hexo"></a>2. 初始化Hexo</h3><p>在你的电脑上创建Hexo文件夹，在cmd终端中切换到Hexo目录，输入命令<code>hexo init</code></p>
<h3 id="3-获取博客主题"><a href="#3-获取博客主题" class="headerlink" title="3. 获取博客主题"></a>3. 获取博客主题</h3><p>在cmd中输入命令：<br><code>git clone https://gitee.com/xiuxiuing/hexo-theme-even themes/even</code></p>
<p>克隆完成后，在<code>/Hexo/themes</code> 目录下，可以看到 <code>landscape</code> 和<code>even</code> 两个文件夹。<br>我们所要使用的主题都是放在这个目录下，Hexo默认使用的是landscape主题，由于第二步Hexo初始化时主题没有clone成功，所以我们这一步克隆了even主题，接下来会使用even主题进行演示。<br>想获取更多主题，可在网站 <a href="https://hexo.io/themes/" target="_blank" rel="noopener">https://hexo.io/themes/</a> 选择自己喜欢的主题，按照此步的步骤clone下来。</p>
<h3 id="4-config-yml对博客进行基础配置"><a href="#4-config-yml对博客进行基础配置" class="headerlink" title="4. _config.yml对博客进行基础配置"></a>4. _config.yml对博客进行基础配置</h3><p>_config.yml文件修改，保存</p>
<pre class=" language-bash"><code class="language-bash"><span class="token comment" spellcheck="true"># Site</span>
title: 我是一条老鱼
subtitle:
description:
keywords:
author: LaoYu
language:
timezone:

<span class="token comment" spellcheck="true"># Extensions</span>
<span class="token comment" spellcheck="true">## Plugins: https://hexo.io/plugins/</span>
<span class="token comment" spellcheck="true">## Themes: https://hexo.io/themes/</span>
theme: landscape
</code></pre>
<h3 id="5-本地预览博客"><a href="#5-本地预览博客" class="headerlink" title="5. 本地预览博客"></a>5. 本地预览博客</h3><p>编译项目，输入命令：<code>hexo g</code></p>
<p>运行项目，输入命令：<code>hexo s</code></p>
<p>在浏览器中输入<code>http://localhost:4000/</code>就可以看到效果啦</p>
<h2 id="部署博客到Gitee上"><a href="#部署博客到Gitee上" class="headerlink" title="部署博客到Gitee上"></a>部署博客到Gitee上</h2><h3 id="1-创建Gitee账号"><a href="#1-创建Gitee账号" class="headerlink" title="1. 创建Gitee账号"></a>1. 创建Gitee账号</h3><p>到码云：<a href="https://gitee.com/" target="_blank" rel="noopener">https://gitee.com/</a> 上申请注册账号，码云类似国内版的GitHub，所以操作界面跟GitHub差不多，多了一些国产化的东西，这里不做更多介绍了，自己研究下。</p>
<h3 id="2-创建项目"><a href="#2-创建项目" class="headerlink" title="2. 创建项目"></a>2. 创建项目</h3><p>创建完成后，在项目中复制项目地址。</p>
<h3 id="3-在-config-yml中配置Git"><a href="#3-在-config-yml中配置Git" class="headerlink" title="3. 在_config.yml中配置Git"></a>3. 在_config.yml中配置Git</h3><pre class=" language-bash"><code class="language-bash"><span class="token comment" spellcheck="true"># URL</span>
<span class="token comment" spellcheck="true">## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'</span>
url: http://lexizhi.gitee.io/blog
root: /blog
permalink: :year/:month/:day/:title/
permalink_defaults:

<span class="token comment" spellcheck="true"># Deployment</span>
<span class="token comment" spellcheck="true">## Docs: https://hexo.io/docs/deployment.html</span>
deploy:
  type: <span class="token function">git</span>
  repo: https://gitee.com/lexizhi/blog.git
  banch: master
</code></pre>
<p>注意：冒号后面一定要有空格，否则不能正确识别。</p>
<h3 id="4-发布到Gitee"><a href="#4-发布到Gitee" class="headerlink" title="4. 发布到Gitee"></a>4. 发布到Gitee</h3><p>输入命令<code>npm install hexo-deployer-git --save</code> 安装自动部署发布工具</p>
<p>输入命令<code>hexo clean</code> &amp;&amp; <code>hexo g</code> &amp;&amp; <code>hexo d</code> 发布博客，首次发布需要在cmd中输入账号和密码。</p>
<h3 id="5-Gitee-Pages设置"><a href="#5-Gitee-Pages设置" class="headerlink" title="5. Gitee Pages设置"></a>5. Gitee Pages设置</h3><p>在项目的服务中选择Pages选项</p>
<p>选择 master分支，点击 部署/更新</p>
<p>稍等一会儿博客就发布成功啦，访问博客地址：<a href="https://lexizhi.gitee.io/blog">https://lexizhi.gitee.io/blog</a>，就可预览在线博客啦！！！</p>
<p>注意1：如果博客的样式不对，则需要在_config.yml中配置下博客地址和路径，或者是因为关闭了hexo，在cmd输入hexo s即可。</p>

    </div>
    
    <div class="post-footer">
        <div>
            
                转载声明：商业转载请联系作者获得授权,非商业转载请注明出处 © <a href target="_blank">Snippet</a>
            
        </div>
        <div>
            
        </div>
    </div>
</article>

<div class="article-nav prev-next-wrap clearfix">
    
        <a href="/blog/2019/05/26/Nodejs npm cnpm 自定义安装配置/" class="pre-post btn btn-default" title="Nodejs npm cnpm 自定义安装配置">
            <i class="fa fa-angle-left fa-fw"></i><span class="hidden-lg">上一篇</span>
            <span class="hidden-xs">Nodejs npm cnpm 自定义安装配置</span>
        </a>
    
    
        <a href="/blog/2019/05/26/hello-world/" class="next-post btn btn-default" title="Hello World">
            <span class="hidden-lg">下一篇</span>
            <span class="hidden-xs">Hello World</span><i class="fa fa-angle-right fa-fw"></i>
        </a>
    
</div>


    <div id="comments">
        
	
    <div id="vcomments" class="valine"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="/blog/assets/valine.min.js"></script>

    <script>
        new Valine({
            av: AV,
            el: '#vcomments',
            appId: 'xOKV9J4UeQAtVkvnJC7Kq2Jn-gzGzoHsz',
            appKey: 'erIpQac4azoCmgfBB7Dl9maa',
            placeholder: '说点什么吧',
            notify: false,
            verify: true,
            avatar: 'mm',
            meta: 'nick,mail'.split(','),
            pageSize: '10',
            path: window.location.pathname,
            lang: 'zh-CN'.toLowerCase()
        })
    </script>


    </div>





                </main>
                
                    <aside id="article-toc" role="navigation" class="col-md-4">
    <div class="widget">
        <h3 class="title">文章目录</h3>
        
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#为何使用Gitee而不是GitHub"><span class="toc-text">为何使用Gitee而不是GitHub</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#开始搭建"><span class="toc-text">开始搭建</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-安装Hexo"><span class="toc-text">1. 安装Hexo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-初始化Hexo"><span class="toc-text">2. 初始化Hexo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-获取博客主题"><span class="toc-text">3. 获取博客主题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-config-yml对博客进行基础配置"><span class="toc-text">4. _config.yml对博客进行基础配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-本地预览博客"><span class="toc-text">5. 本地预览博客</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#部署博客到Gitee上"><span class="toc-text">部署博客到Gitee上</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-创建Gitee账号"><span class="toc-text">1. 创建Gitee账号</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-创建项目"><span class="toc-text">2. 创建项目</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-在-config-yml中配置Git"><span class="toc-text">3. 在_config.yml中配置Git</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-发布到Gitee"><span class="toc-text">4. 发布到Gitee</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-Gitee-Pages设置"><span class="toc-text">5. Gitee Pages设置</span></a></li></ol></li></ol>
        
    </div>
</aside>

                
            </div>
        </div>
    </section>
    <footer class="main-footer">
    <div class="container">
        <div class="row">
        </div>
    </div>
</footer>

<a id="back-to-top" class="icon-btn hide">
	<i class="fa fa-chevron-up"></i>
</a>




    <div class="copyright">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="busuanzi">
    
        访问量:
        <strong id="busuanzi_value_site_pv">
            <i class="fa fa-spinner fa-spin"></i>
        </strong>
        &nbsp; | &nbsp;
        访客数:
        <strong id="busuanzi_value_site_uv">
            <i class="fa fa-spinner fa-spin"></i>
        </strong>
    
</div>

            </div>
            <div class="col-sm-12">
                <span>Copyright &copy; 2017
                </span> |
                <span>
                    Powered by <a href="//hexo.io" class="copyright-links" target="_blank" rel="nofollow">Hexo</a>
                </span> |
                <span>
                    Theme by <a href="//github.com/shenliyang/hexo-theme-snippet.git" class="copyright-links" target="_blank" rel="nofollow">Snippet</a>
                </span>
            </div>
        </div>
    </div>
</div>






    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>


<script src="/blog/js/app.js?rev=@@hash"></script>

</body>
</html>